package mgo

import (
	"context"
	"go.mongodb.org/mongo-driver/mongo"
)

// GetCollection 获取集合
func GetCollection(client *mongo.Client, db, name string) *mongo.Collection {
	return client.Database(db).Collection(name)
}

// DeleteCollection 删除集合
func DeleteCollection(ctx context.Context, collection *mongo.Collection) error {
	return collection.Drop(ctx)
}

// GetCollectionName 获取集合名称
func GetCollectionName(collection *mongo.Collection) string {
	return collection.Name()
}

// GetDatabaseName 获取集合所属数据库名称
func GetDatabaseName(collection *mongo.Collection) string {
	return collection.Database().Name()
}
